package com.symaster.backups.frame.page.viewfiles;

import com.symaster.backups.frame.dialog.AddMonitorFolderDialog;
import com.symaster.backups.frame.element.layout.TileLayout;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author yinmiao
 * @version 2024/2/5
 */
public class FileBackupToolbar extends JComponent {
    private final FileBackupView fileBackupView;
    private final AddMonitorFolderDialog addMonitorFolderDialog;

    public FileBackupToolbar(FileBackupView fileBackupView, AddMonitorFolderDialog addMonitorFolderDialog) {
        this.fileBackupView = fileBackupView;
        this.addMonitorFolderDialog = addMonitorFolderDialog;
        setLayout(new TileLayout(5));
        JButton jButton = new JButton("添加自动备份目录");
        jButton.setMargin(new Insets(7, 7, 7, 7));
        jButton.addActionListener(e -> {
            if (e.getSource() instanceof JButton jButton1) {
                Point locationOnScreen = jButton1.getLocationOnScreen();
                addMonitorFolderDialog.pack();
                addMonitorFolderDialog.setBounds(locationOnScreen.x, locationOnScreen.y, 400,300);
                addMonitorFolderDialog.setVisible(true);
            }

        });
        add(jButton);
    }
}
